package org.pz.camunda.delegate;

import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.pz.entity.AskForLevelEntity;
import org.pz.wrapper.BeanWrapperUtil;
import org.springframework.stereotype.Component;

/**
 * 这里创建一个 bean，用与请假流程最后一个系统节点
 * */
@Slf4j
@Component("askForLevel_system")
public class AskForLevelSystemDelegate implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) throws Exception {

        log.info("系统节点-提交申请！");

        AskForLevelEntity entity = BeanWrapperUtil.mapToEntity(execution.getVariables(), AskForLevelEntity.class);

        //todo 在这里设置下一个节点的任务处理人（人事），这里也暂时设置 admin
        entity.setPersonnelMattersId("admin");

        log.info("系统节点-提交申请，流程数据：{}", execution.getVariables());
    }
}
